// 组件允许单个组件打包，因此默认引入公共基础样式

@import "../../base.less";

@import "./_var.less";

@import "./_mixin.less";

.@{prefix}-date-picker {
  padding: 0;

  .@{prefix}-date-picker__popup-reference {
    width: 100%;
  }

  &__container {
    border-radius: @datepicker-panel-border-radius;
    background-color: @datepicker-dropdown-background;
    overflow: auto;
  }

  .@{prefix}-is-active {
    input {
      border-color: @datepicker-input-border-color-active;
      box-shadow: @datepicker-input-shadow;
    }
  }
}

.@{prefix}-date-picker__panels {
  display: flex;
  min-width: 320px;
  max-width: 100%;
  background-color: @datepicker-background;

  &::after {
    display: block;
    clear: both;
    content: "";
  }
}

.@{prefix}-date-picker--panel {
  position: relative;
  width: @datepicker-panel-width;
  margin: 0;

  &:nth-child(2) {
    &::before {
      content: " ";
      width: 1px;
      height: 95%;
      display: block;
      position: absolute;
      left: 0;
      top: 16px;
      border-left: 1px solid @datepicker-border-color;
    }
  }
}

.@{prefix}-date-picker__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid @border-level-1-color;

  .@{prefix}-date-picker__header-title,
  .@{prefix}-date-picker__header-btn {
    font-size: @datepicker-font-size-l;
    font-weight: @datepicker-font-weight-medium;
  }

  .@{prefix}-date-picker__header-controller {
    &__btn {
      color: @datepicker-button-text-color;
      padding: 4px;
      width: 32px;

      .@{prefix}-icon {
        font-size: 16px;
      }

      &:nth-child(2) {
        margin: 0 8px;
      }
    }

    &__btn--now {
      color: @datepicker-button-text-color;
    }
  }
}

.@{prefix}-date-picker__cell {
  &-wrapper {
    height: @datepicker-cell-width-default;
    margin-top: 4px;
    width: 100%;
    cursor: pointer;
    position: relative;

    > span {
      display: block;
      width: @datepicker-cell-width-default;
      line-height: @datepicker-cell-width-default;
      border-radius: 50%;
      position: absolute;
      left: 50%;
      transform: translateX(-50%);
      z-index: 10;

      &:hover {
        box-shadow: inset 0 0 0 1px @brand-color;
        transition: box-shadow @anim-duration-base @anim-time-fn-ease-in;
      }
    }
  }

  &__text {
    font-size: 14px;
  }

  &--now {

    .@{prefix}-date-picker__cell-wrapper {
      position: absolute;
      top: 0;
      color: @datepicker-now-color;

      &::after {
        display: block;
        content: "";
        height: 6px;
        width: 6px;
        border-radius: 50%;
        background-color: @datepicker-now-color;
        position: relative;
        z-index: 2;
        left: 17px;
        top: 34px;
      }
    }
  }

  &--highlight {

    .@{prefix}-date-picker__cell-wrapper {
      background-color: @datepicker-highlight-color;
      border-color: @datepicker-highlight-color;
      transition: background @anim-duration-base, border @anim-duration-base;

      &::after {
        display: none;
      }
    }
  }

  &--additional {

    .@{prefix}-date-picker__cell-wrapper {
      color: @datepicker-disabled-color;
      background: @bg-color-container;

      > span {
        color: @datepicker-disabled-color;

        &:hover {
          box-shadow: none;
        }
      }
    }
  }

  &--active {

    .@{prefix}-date-picker__cell-wrapper {
      & > span {
        color: @text-color-anti;
        background-color: @brand-color;
      }

      &::after {
        display: none;
      }
    }

    &-start {

      .@{prefix}-date-picker__cell-wrapper {
        border-top-left-radius: 50%;
        border-bottom-left-radius: 50%;
      }
    }

    &-end {

      .@{prefix}-date-picker__cell-wrapper {
        border-top-right-radius: 50%;
        border-bottom-right-radius: 50%;
      }
    }
  }

  &--last-day-of-month {

    .@{prefix}-date-picker__cell-wrapper {
      border-top-right-radius: 50%;
      border-bottom-right-radius: 50%;
    }
  }

  &--first-day-of-month {

    .@{prefix}-date-picker__cell-wrapper {
      border-top-left-radius: 50%;
      border-bottom-left-radius: 50%;
    }
  }

  &--disabled {

    .@{prefix}-date-picker__cell-wrapper {
      cursor: not-allowed;
      border-radius: 50%;
      background-color: @datepicker-disabled-background;
      border-color: @datepicker-disabled-background;

      > span {
        color: @datepicker-disabled-color;

        &:hover {
          box-shadow: none;
        }
      }
    }
  }

  // disable 相邻需要半圆连接
  &--disabled + &--disabled {

    .@{prefix}-date-picker__cell-wrapper {
      &::before {
        content: "";
        width: 100%;
        height: 100%;
        position: absolute;
        left: -50%;
        top: 0;
        background: @datepicker-disabled-background;
        pointer-events: none;
      }
    }
  }
}

.@{prefix}-date-picker--year {
  padding-bottom: @datepicker-panel-padding;

  tbody {
    tr {

      .@{prefix}-date-picker__cell-wrapper {
        margin-top: 8px;
        height: @datepicker-cell-width-year;

        .@{prefix}-date-picker__cell-text {
          height: @datepicker-cell-width-year;
          width: @datepicker-cell-width-year;
          line-height: @datepicker-cell-width-year;
        }

        &::after {
          left: 36px;
          top: 40px;
        }
      }

      &:first-child {

        .@{prefix}-date-picker__cell-wrapper {
          margin-top: 16px;
        }
      }

      &:last-child {
        .@{prefix}-date-picker__cell {
          text-align: left;
        }
      }
    }
  }
}

.@{prefix}-date-picker--month {
  tbody {
    tr {

      .@{prefix}-date-picker__cell-wrapper {
        margin-top: 8px;

        &::after {
          left: 36px;
        }
      }

      &:first-child {

        .@{prefix}-date-picker__cell-wrapper {
          margin-top: 20px;
        }
      }

      &:last-child {

        .@{prefix}-date-picker__cell-wrapper {
          margin-bottom: 12px;
        }
      }
    }
  }
}

.@{prefix}-date-picker--date {
  padding: 0 16px 16px;
}

.@{prefix}-date-picker__panel {
  width: 320px;

  table {
    width: 100%;
    border-collapse: collapse;
    user-select: none;
    padding: 0 16px 16px;
  }

  tbody {
    font-weight: @datepicker-font-weight-medium;
    margin-top: 2px;
  }

  th {
    color: @datepicker-th-font-color;
    padding: 16px 0 8px;
    margin-bottom: 5px;
    width: 46px;
    font-weight: @datepicker-th-font-weight;
  }

  td {
    padding: 0;
    text-align: center;
    position: relative;

    // 每列开头和结尾均为圆形边框
    &:first-child {
      .@{prefix}-date-picker__cell-wrapper {
        border-top-left-radius: 50%;
        border-bottom-left-radius: 50%;
      }
    }

    &:last-child {
      .@{prefix}-date-picker__cell-wrapper {
        border-top-right-radius: 50%;
        border-bottom-right-radius: 50%;
      }
    }
  }

  &__sub-panel {
    &--hide {
      display: none;
    }
  }
}

.@{prefix}-date-picker__panels {
  overflow: hidden;
  display: flex;
}

.@{prefix}-date-picker__footer {
  width: 320px;
  display: flex;
  align-items: flex-start;
}

.@{prefix}-date-picker--range {

  .@{prefix}-date-picker__footer {
    width: 640px;
  }
}

.@{prefix}-date-picker__presets {
  margin: @datepicker-btn-margin;
  min-width: 100px;
  justify-content: space-between;
  flex: 1;

  ul {
    list-style: none;
    margin: 0 auto;
    padding: 0;
    width: 100%;
  }

  li {
    font-size: @datepicker-font-size;
    line-height: @datepicker-line-height;
    font-weight: 400;
    white-space: nowrap;
    padding: 0;
    cursor: pointer;
    float: left;
    margin-right: 16px;

    &:last-child {
      margin: 0;
    }

    a {
      color: @datepicker-presets-text-color;

      &:hover {
        color: @datepicker-presets-text-color-hover;
      }
    }
  }
}

.@{prefix}-date-picker--apply {
  margin: @datepicker-btn-margin;
  display: flex;

  > button:last-child {
    margin-left: @datepicker-apply-btn-margin;
  }
}
